cmake_minimum_required(VERSION 2.8)
project(fast_tffm)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11")
if (APPLE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -undefined dynamic_lookup")
elseif (UNIX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
execute_process(COMMAND python -c "import tensorflow as tf; print(tf.sysconfig.get_include())" OUTPUT_VARIABLE tf_inc)
include_directories(${tf_inc})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/)
add_library(fast_tffm SHARED cc/fm_grad_op.cc cc/fm_parser_op.cc cc/fm_scorer_op.cc)
enable_testing()
add_test(NAME test_scorer COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/test/fm_scorer_op_test.py)
add_test(NAME test_parser COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/test/fm_parser_op_test.py)
